package com.dy.spring.message;

import com.dy.spring.client.StreamClient;
import com.dy.spring.entities.UserEntity;
import lombok.extern.log4j.Log4j2;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * @author huangdeyao
 * @date 2019/7/2 13:04
 */
@Component
@EnableBinding(StreamClient.class)
@Log4j2
public class StreamReceiver {

//    @StreamListener(StreamClient.STREAM_INPUT)
//    public void receive(Object message) {
//        log.info("stream input receiver: {}", message);
//    }

    @StreamListener(StreamClient.STREAM_INPUT)
    @SendTo(StreamClient.STREAM_INPUT_2)
    public UserEntity process(UserEntity userEntity) {
        log.info("stream input receiver: {}", userEntity.toString());
        return userEntity;
    }

    @StreamListener(StreamClient.STREAM_INPUT_2)
    public void process2(UserEntity userEntity) {
        log.info("STREAM_INPUT_2  input receiver: {}", userEntity.toString());
    }
}
